package com.iplay.实战java高并发程序设计.chapter5.c510;

import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;

/**
 * @author dangwu
 * @since 2021/11/9 8:23 下午
 */
public class HandleMsg implements Runnable{
    SelectionKey sk;
    ByteBuffer bb;
    public HandleMsg(SelectionKey sk,ByteBuffer bb){
        this.sk = sk;
        this.bb = bb;
    }
    @Override
    public void run() {
        EchoClient echoClient = (EchoClient)sk.attachment();
        echoClient.enqueue(bb);
        sk.interestOps(SelectionKey.OP_READ|SelectionKey.OP_WRITE);

    }
}
